<?php
// +----------------------------------------------------------------------
// | OneKeyAdmin [ Believe that you can do better ]
// +----------------------------------------------------------------------
// | Copyright (c) 2020-2023 http://onekeyadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: MUKE <513038996@qq.com>
// +----------------------------------------------------------------------
namespace plugins\cms\api\controller;

use think\exception\ValidateException;
use app\api\BaseController;
use plugins\cms\api\validate\Banner as Validate;
use plugins\cms\api\model\Banner as BannerModel;
/**
 * 幻灯片
 */
class Banner extends BaseController
{
    /**
     * 列表
     */
    public function index()
    {
        if ($this->request->isPost()) {
            try {
                $input = input('post.');
                validate(Validate::class)->scene('index')->check($input);
            } catch ( ValidateException $e ) {
                return json(['status' => 'error', 'message' => $e->getError()]);
            }
            $order  = ['sort' => 'desc'];
            $append = ['url','catalog_title'];
            $search = ['catalog_id'];
            $data   = BannerModel::withSearch($search, $input)->order($order)->append($append)->select();
            return json(['status' => 'success','message' => '获取成功', 'data' => $data]);
        }
    }
}